package com.luchao.blockchain.model;

import java.util.List;

/**
 * 区块结构
 * @author ZhaoLu
 *
 */
public class Block {
	//区块索引
	private int index;
	//当前区块的hash值，区块唯一标示
	private String hash;
	//生成区块的时间戳
	private long timesamp;
	//当前区块的交易记录
	private List<Transaction> transactions;
	//工作证明，计算正确hash值的次数
	private int nonce;
	//前一个区块的hash值
	private String previousHash;
	
	/**
	 * 
	 * @param index 区块索引
	 * @param hash 当前区块的hash值，区块唯一标示
	 * @param timesamp 生成区块的时间戳
	 * @param transactions 当前区块的交易记录
	 * @param noce 工作证明，计算正确hash值的次数
	 * @param previousHash 前一个区块的hash值
	 */
	public Block(int index, String hash, long timesamp, List<Transaction> transactions, int nonce, String previousHash) {
		super();
		this.index = index;
		this.hash = hash;
		this.timesamp = timesamp;
		this.transactions = transactions;
		this.nonce = nonce;
		this.previousHash = previousHash;
	}
	
	public int getIndex() {
		return index;
	}
	public void setIndex(int index) {
		this.index = index;
	}
	public String getHash() {
		return hash;
	}
	public void setHash(String hash) {
		this.hash = hash;
	}
	public long getTimesamp() {
		return timesamp;
	}
	public void setTimesamp(long timesamp) {
		this.timesamp = timesamp;
	}
	public List<Transaction> getTransactions() {
		return transactions;
	}
	public void setTransactions(List<Transaction> transactions) {
		this.transactions = transactions;
	}
	public int getNonce() {
		return nonce;
	}
	public void setNonce(int nonce) {
		this.nonce = nonce;
	}
	public String getPreviousHash() {
		return previousHash;
	}
	public void setPreviousHash(String previousHash) {
		this.previousHash = previousHash;
	}

}
